<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@include file="../common/jspcommon.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>我的订单 - 爽客网</title>
<%@include file="../common/js.jsp" %>
<%@include file="../common/css.jsp" %>
<link href="/css/base/hf.css" type="text/css" rel="stylesheet" />
<link href="/css/other.css" type="text/css" rel="stylesheet" />
</head>
<body>
	 <!-- head -->
	<%@include file="../common/header.jsp" %>
	<!-- header-->
	<div class="wrap">
    	<div class="w965 mg i_main_box">
        	<!-- left -->
           <%@include file="myLeft.jsp" %>
            <!-- left--end-->
             <div class="i_right_box" style="height:1500px;">
            	<div class="order_box">
                	<h1>我的订单</h1>
                    <!-- order-->
                    <div class="mb10">
                        <table class="order_detail">
                            <tr class="row1">
                                <td width="50">订单号</td>
                                <td width="200">预订产品</td>
                                <td width="55">应付金额</td>
                                <td width="100">下单时间</td>
                                <td width="70">支付方式</td>
                                <td width="60">订单状态</td>
                                <td>操作</td>
                            </tr>
                            <c:forEach items="${orderModel.list}" var="myOrder">
                            <tr>
                                 	<td ><a href="orderDetail.htm?id=${myOrder.id}" target="_blank">${myOrder.id}</a></td>
                                
                               		<td>
                               		<c:forEach items="${myOrder.opList}" var="product">
                               			<a  target="_blank"
                               			<c:choose>
		                                	<c:when test="${myOrder.type=='01'}">
		                                		 href="ticket.htm?id=${product.pid}"
		                                	</c:when>
		                                	<c:when test="${myOrder.type=='02'}">
		                                		 href="hotel.htm?rid=${product.pid}"
		                                	</c:when>
		                                	<c:when test="${myOrder.type=='03'}">
		                                		 href="product.htm?id=${product.pid}"
		                                	</c:when>
		                                </c:choose>
	                               >${product.pname}</a>
                               		</c:forEach>
                               		</td>
	                                <td><span class="farial clrf60">¥${myOrder.totalFee}</span></td>
	                                <td>
	                                <fmt:formatDate value="${myOrder.gmtCreated}" pattern="MM-dd HH:mm" />
	                                </td>
	                                <td>
		                                <c:if test="${myOrder.payFrom=='01'}">线上支付</c:if>	
		                                <c:if test="${myOrder.payFrom=='02'}">到付</c:if>	
	                                </td>
	                                <td>
										<c:if test="${myOrder.status=='01'}">待支付</c:if> 
										<c:if test="${myOrder.status=='02'}">已支付</c:if> 
										<c:if test="${myOrder.status=='03'}">已成功</c:if> 
										<c:if test="${myOrder.status=='04'}">已完成</c:if> 
										<c:if test="${myOrder.status=='05'}">已取消</c:if> 
										<c:if test="${myOrder.status=='06'}">挂起</c:if> 
									</td>
	                                <td>
		                                <c:if test="${myOrder.status=='01' && myOrder.payFrom=='01'}">
		                                	<a href="orderView.htm?id=${myOrder.id}"  class="btn" target="_blank"><span>进行支付</span></a>
		                                </c:if>
		                                <c:if test="${myOrder.status=='01'}">
		                                	 <a href="javascript:;" class="btn cancel_btn" orderid='${myOrder.id}'><span>取消</span></a>
		                                </c:if>
	                               </td>
                               </tr>
                                </c:forEach>
                            
                            
                        </table>
                        <div class="fy_box">
                        <c:if test="${orderModel.currentPage!=1}">
                        	<a href="javascript:;" id="page_pre">上一页</a>
                        </c:if>
                        
                        <span>${orderModel.currentPage}</span>
                        <c:if test="${orderModel.currentPage!=orderModel.totalPage}">
                        	<a href="javascript:;" id="page_next">下一页</a>
                        </c:if>
                        
                        </div>
                    </div>
                    <!-- order--end-->
                </div>
            </div>
         
        </div>
    </div>
       <!-- help-->
         <div class="w980 mg box_style1">
        	<c:forEach items="${help }" var="c">
        		${c.content}
        	</c:forEach>
        </div>
        <!-- help--end-->
        
    <!-- content--end-->
	    <!-- foot-->
	    <%@include file="../common/footer.jsp" %>
	    <!-- foot--end-->
  		<script type="text/javascript">
          		$(function(){
          			$("#page_pre").click(function(){
          				var url = "myOrder.htm?page="+(parseInt('${orderModel.currentPage}')-1);
						window.location.href = url;
          			});
          			
					$("#page_next").click(function(){
						var url = "myOrder.htm?page="+(parseInt('${orderModel.currentPage}')+1);
						window.location.href = url;
	          		});
          			
          			
          			$(".cancel_btn").click(function(){
          				if(confirm("你确定要取消该订单吗？")){
          					$.post("cancelOrder.htm",{
          						"id": $(this).attr('orderid')
          					},function(data){
          						if(data == 'success'){
									window.location.reload();
          						}else{
          							alert('订单状态已改变，不能取消！');
          							window.location.reload();
          						}
          					});
          				}
          			});
          			
          		});
          		
          </script>
</body>
</html>